#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
//在升序数组中查找某个数出现的次数
int GetNumberOfK(int* p, int sz, int k)
{
	int Left = 0;
	int Right = 0;
	int left = 0;
	int right = sz - 1;
	int mid = 0;
	while (left <= right)
	{
		mid = (right - left) / 2 + left;
		if (*(p + mid) >= k)
		{
			right = mid - 1;
		}
		else
		{
			do 
			{
				mid += 1;
			} while (*(p+mid) < k);
			Left = mid - 1;
			break;
		}
	}
	left = 0;
	right = sz - 1;
	mid = 0;
	while (left <= right)
	{
		mid = (right - left) / 2 + left;
		if (*(p + mid) <= k)
		{
			left = mid + 1;
		}
		else
		{
			do
			{
				mid -= 1;
			} while (*(p + mid) > k);
			Right = mid + 1;
			break;
		}
	}
	return Right - Left - 1;
}

int main()
{
	int arr[] = { 1, 1, 1, 4, 4, 4, 4, 5 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	int k = 0;
	scanf("%d", &k);
	int ret = GetNumberOfK(arr, sz, k);
	printf("%d", ret);
	return 0;
}